#include "student_list_view.h"
#include "ui_student_list_view.h"
#include "widget_student_list_view_item.h"
#include "widget_header_buttons.h"
#include <QDebug>

student_list_view::student_list_view(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::student_list_view)
{
    setMainWindowTitle("Student List");
    ui->setupUi(this);
    ui->gridLayout_2->addWidget(new widget_header_buttons(this),0,0,0,0);
    widget_student_list_view_item *listviewitems[6];
    listviewitems[0] = new widget_student_list_view_item(
                this,
                "Alan Baker",
                "2:23pm",
                "Bio 100 Midterm 1",
                21,
                55);
    listviewitems[0]->hide_chat_icon();
    listviewitems[1] = new widget_student_list_view_item(
                this,
                "Claire DeMoiyer",
                "2:54pm",
                "Chem 230 Midterm 3",
                12,
                65);
    listviewitems[2] = new widget_student_list_view_item(
                this,
                "Ellen Fitzgerald",
                "1:30pm",
                "Math 101 Midterm 2",
                96,
                51);
    listviewitems[2]->hide_chat_icon();
    listviewitems[3] = new widget_student_list_view_item(
                this,
                "Greg Harrison",
                "4:44pm",
                "Math 200 Midterm 4",
                45,
                49);
    listviewitems[4] = new widget_student_list_view_item(
                this,
                "Ian Jackson",
                "5:01pm",
                "Mech 200 Midterm 3",
                2,
                45);
    listviewitems[5] = new widget_student_list_view_item(this);
    listviewitems[5]->hide_chat_icon();


    for (size_t i = 0;i < sizeof(listviewitems)/sizeof(*listviewitems);i++){
        QObject::connect(listviewitems[i],SIGNAL(clicked(QMouseEvent*)),
                         this,SLOT(onlistViewItem_clicked(QMouseEvent*)));
    }

    ui->gridLayout->addWidget(listviewitems[0],0,0);
    ui->gridLayout->addWidget(listviewitems[1],0,1);
    ui->gridLayout->addWidget(listviewitems[2],1,0);
    ui->gridLayout->addWidget(listviewitems[3],1,1);
    ui->gridLayout->addWidget(listviewitems[4],2,0);
    ui->gridLayout->addWidget(listviewitems[5],2,1);
}

student_list_view::~student_list_view()
{
    delete ui;
}


void student_list_view::onlistViewItem_clicked(QMouseEvent *){
    qDebug() << "BAM";
    emit (changeScene(STUDENT_VIEW));
}
/*
void student_list_view::on_gototestview_clicked()
{
    emit (changeScene(TEST_VIEW));
}
*/
